package com.study.d029lightbase;

import javafx.application.Application;
import javafx.scene.AmbientLight;
import javafx.scene.PerspectiveCamera;
import javafx.scene.PointLight;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Box;
import javafx.scene.shape.Cylinder;
import javafx.scene.shape.Shape3D;
import javafx.scene.shape.Sphere;
import javafx.stage.Stage;

/**点光源
*@description
*@author xtayhame
*date 2020年3月22日
*version
*since v1.0
*/
public class PointLightMain extends Application{
	public static void main(String[] args) {
		launch(args);
	}
	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane anchorPane = new AnchorPane();
		HBox box = new HBox(40);
		PointLight al = new PointLight();
		al.setColor(Color.valueOf("#8B8B00"));
		//移动光源
		al.setTranslateX(400);
		al.setTranslateY(300);

		Box b1  = new Box(100, 100, 100);
		Sphere b2 = new Sphere(50, 200);
		Cylinder b3 = new Cylinder(50, 150);
		//将光源加入到容器中，默认多容器中的所有组件有效
		box.getChildren().addAll(b1,b2,b3,al);
		anchorPane.getChildren().add(box);
		Scene scene = new Scene(anchorPane, 600, 400, true);
		//添加摄像机
		scene.setCamera(new PerspectiveCamera());
		stage.setScene(scene);
		stage.centerOnScreen();
		stage.show();



	}
}
